package com.ljh.service.Impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ljh.mapper.CollectionMapper;
import com.ljh.mapper.SongMapper;
import com.ljh.pojo.Collection;
import com.ljh.service.CollectionService;
import com.ljh.service.SongService;
import com.ljh.vo.CollectionSongVo;
import com.ljh.vo.SongListVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class CollectionServiceImpl extends ServiceImpl<CollectionMapper,Collection> implements CollectionService {

    @Autowired
    public CollectionMapper collectionMapper;

    @Autowired
    public SongMapper songMapper;


    @Override
    public List<Collection> findCollection() {
        return collectionMapper.findAllColl();
    }

    @Override
    public CollectionSongVo findCollSong(Integer id) {
        CollectionSongVo collectionSongVo = new CollectionSongVo();
        List<SongListVo> songListVo = songMapper.findSongListVo(id);
        collectionSongVo.setSongs(songListVo);
        Collection collById = collectionMapper.findCollById(id);
        collectionSongVo.setCollection(collById);
        return collectionSongVo;
    }

    @Override
    public List<Collection> findCollByUserId(Integer userId) {
        return collectionMapper.findCollByUserId(userId);
    }

    @Override
    public void deleteCollByUserId(Integer userId) {
        collectionMapper.deleteCollByUserId(userId);
    }

    @Override
    public void deleteCollById(Integer collId) {
        collectionMapper.deleteCollById(collId);
    }

    @Override
    public void updateListPhoto(String collPhoto, Integer collId) {
        collectionMapper.updateListPhoto(collPhoto, collId);
    }

    @Override
    public Collection findCollById(Integer id) {
        return collectionMapper.findCollById(id);
    }

    @Override
    public void insertCollection(String collName, String collDate, Integer singerId, String singerName) {
        collectionMapper.insertCollection(collName, collDate, singerId, singerName);
    }

    @Override
    public void updateColl(String collName, String singerName, String collDate, Integer collId) {
        collectionMapper.updateColl(collName, singerName, collDate, collId);
    }


}
